//
//  Protocols.swift
//  Media
//
//  Created by han on 2021/6/8.
//

import Foundation
import UIKit

// MARK: Extensions
struct ExtensionType<T> {
    let value: T
    init(_ value: T) {
        self.value = value
    }
}

protocol ExtensionProtocol {
    associatedtype T
    static var md: ExtensionType<T>.Type { set get }
    var md: ExtensionType<T> { set get }
}

extension ExtensionProtocol {
    static var md: ExtensionType<Self>.Type {
        set {}
        get { ExtensionType<Self>.self }
    }
    
    var md: ExtensionType<Self> {
        set {}
        get { ExtensionType<Self>(self) }
    }
}

extension UIColor: ExtensionProtocol {}
extension ExtensionType where T: UIColor {
    static var white: UIColor { UIColor.brown }
}


// MARK: reuse identifier
protocol ReuseIdentifierProtocol {
   static var identifier: String { get }
}

extension ReuseIdentifierProtocol where Self: UIView {
    static var identifier: String {
        return "k\(String(describing: self))Identifier"
    }
}

extension UITableViewCell: ReuseIdentifierProtocol {}
extension UITableViewHeaderFooterView: ReuseIdentifierProtocol {}
extension UICollectionReusableView: ReuseIdentifierProtocol {}


// MARK: storyboard identifier
protocol StoryboardIdentifierProtocol {
    static var identifier: String { get }
}

extension StoryboardIdentifierProtocol where Self: UIViewController {
    static var identifier: String {
        return String(describing: self)
    }
}

extension UIViewController: StoryboardIdentifierProtocol {}
